#ifndef __NUMBER_H_INCLUDE__
#define __NUMBER_H_INCLUDE__

/* $Id: number.h 144 2009-06-16 18:14:08Z zealcook $ */

#include <sysdep.h>	/* basic type */

typedef unsigned int	calc_int;
typedef char	calc_char;
typedef struct calc_num *number;

#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif

#ifndef MIN
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#endif

#ifndef ABS
#define ABS(a) ((a < 0) ? -(a) : (a))
#endif

#define BASE_MASK	0x0A

typedef enum {
	PLUS,
	MINUS,
} calc_sign;

struct calc_num {
	calc_sign	sign;		/* sign */
	calc_int	int_len;	/* integer length */
	calc_int	sca_len;	/* decimal length */
	calc_char	*value;		/* data space */
	int		refs;		/* reference count */
	struct calc_num *next;
};

number new_nbr(unsigned int int_len, unsigned int scale_len);
int free_nbr(number nbr);
number str_to_number(char *str);
char *number_to_str(number num, char *buffer, size_t *length);
/* computer */
number base_add(number a, number b);
number base_sub(number a, number b);
number base_mul(number a, number b);
int number_test(void);
void print_num(number a);

#endif /* __NUMBER_H_INCLUDE__ */
